package com.syni.mdd.sjb.common.datatreaure.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.DankBusinessVerRecord;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.mapper.DankBusinessVerRecordMapper;
import com.syni.mdd.sjb.common.component.utils.common.service.UtilsCommonService;
import com.syni.mdd.sjb.common.component.utils.common.utils.*;
import com.syni.mdd.sjb.common.component.utils.feign.dto.mddAll.apiCoupon.SearchCouponDetailDto;
import com.syni.mdd.sjb.common.component.utils.feign.dto.mddAll.apiCoupon.SearchDto;
import com.syni.mdd.sjb.common.component.utils.feign.dto.mddAll.apiCoupon.VerByNoDto;
import com.syni.mdd.sjb.common.component.utils.feign.dto.mddUser.apiUser.GetMidongdongUserDto;
import com.syni.mdd.sjb.common.component.utils.feign.service.mdd.commonuser.UserRestService;
import com.syni.mdd.sjb.common.component.utils.feign.service.mddAll.CouponRestService;
import com.syni.mdd.sjb.common.datatreaure.constants.Constants;
import com.syni.mdd.sjb.common.datatreaure.constants.ResultCode;
import com.syni.mdd.sjb.common.datatreaure.constants.ResultMsg;
import com.syni.mdd.sjb.common.datatreaure.entity.bo.dataBankBusiness.QueryYXGJCodeBo;
import com.syni.mdd.sjb.common.datatreaure.entity.bo.dataBankBusiness.UnifiedCodeQueryBo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rp.dataBankBusiness.GetMddGroupBuyCouponDetailRpVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rp.dataBankBusiness.UnifiedCodeQueryRpVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rp.minAppLogin.SearchConsumerCouponDetailRpVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.databank.UnifiedCodeQueryVo;
import com.syni.mdd.sjb.common.datatreaure.enums.UnifiedCodeQueryEnums;
import com.syni.mdd.sjb.common.datatreaure.service.DankBusinessVerRecordService;
import com.syni.mdd.sjb.common.datatreaure.service.DankMerchantsDefBusinessService;
import com.syni.mdd.sjb.common.datatreaure.service.UserService;
import com.syni.mdd.sjb.common.datatreaure.service.feignService.YXGJService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 统一核销记录表 服务实现类
 * </p>
 *
 * @author lcc
 * @since 2020-09-23
 */
@Service
@Log4j2
public class DankBusinessVerRecordServiceImpl extends ServiceImpl<DankBusinessVerRecordMapper, DankBusinessVerRecord> implements DankBusinessVerRecordService {
    @Autowired
    CouponRestService couponRestService;

    @Autowired
    YXGJService yxgjService;

    @Autowired
    UserRestService userRestService;

    @Autowired
    UserService userService;

    @Autowired
    DankMerchantsDefBusinessService dankMerchantsDefBusinessService;

    @Autowired
    UtilsCommonService utilsCommonService;

    @Override
    public Map<String, Object> unifiedCodeQuery(UnifiedCodeQueryVo unifiedCodeQueryVo) {
        if(StringUtils.isBlank(unifiedCodeQueryVo.getQrCodeParameters())
                && StringUtils.isBlank(unifiedCodeQueryVo.getInputSearchCode())){
            return ResultMapHelper.result(UnifiedCodeQueryEnums.IDENTIFICATION_FAILURE);
        }
        try {
            if(StringUtils.isNotBlank(unifiedCodeQueryVo.getQrCodeParameters())){
                //扫码核销
                String[] qRCodeParametersArray = unifiedCodeQueryVo.getQrCodeParameters().split("_");
                String qRCodeParameters = WebUtils.handleUriParams(qRCodeParametersArray[2]);
                unifiedCodeQueryVo.setUnifiedType(qRCodeParametersArray[1]);
                UnifiedCodeQueryBo unifiedCodeQueryBo = JSON.parseObject(qRCodeParameters,UnifiedCodeQueryBo.class);
                //处理核销逻辑
                if(unifiedCodeQueryVo.getUnifiedType().equals(Constants.CODE_TYPE_MDD)){
                    return handleMddVerNo(unifiedCodeQueryVo,unifiedCodeQueryBo);
                }else if(unifiedCodeQueryVo.getUnifiedType().equals(Constants.CODE_TYPE_YXGJ)){
                    return handleYXGJVerNo(unifiedCodeQueryVo.getUserId(),unifiedCodeQueryBo.getVerNo());
                }else if(unifiedCodeQueryVo.getUnifiedType().equals(Constants.CODE_TYPE_SAASZT)){
                    return handleSaasztVerNo(unifiedCodeQueryVo.getUserId(),unifiedCodeQueryBo.getVerNo());
                }
            }else{
                //输入码核销
                String code = unifiedCodeQueryVo.getInputSearchCode();
                if(code.startsWith(Constants.CODE_MARKETING_TOOLS)){
                    //TODO营销工具的码
                    return handleYXGJVerNo(unifiedCodeQueryVo.getUserId(),code);
                }else if(code.startsWith(Constants.CODE_SAAS_ZT)) {
                    return handleSaasztVerNo(unifiedCodeQueryVo.getUserId(),code);
                }else {
                    //觅东东这边的券码
                    UnifiedCodeQueryBo unifiedCodeQueryBo = new UnifiedCodeQueryBo();
                    unifiedCodeQueryBo.setVerNo(unifiedCodeQueryVo.getInputSearchCode());
                    return handleMddVerNo(unifiedCodeQueryVo,unifiedCodeQueryBo);
                }
            }
        }catch (Exception e){ log.error(e.getMessage(),e);
        }
        return ResultMapHelper.result(UnifiedCodeQueryEnums.IDENTIFICATION_FAILURE);
    }



    private QueryYXGJCodeBo queryYXGJCode(Integer userId,String code) {
        String accountId = userService.getAccountIdByUserMap(userId);
        if(StringUtils.isNotBlank(accountId)){
            log.info("accountId :{}",accountId);
            Map<String,Object> responseBody = yxgjService.isVerifiPrize(accountId,code);
            log.info("isVerifiPrize : " + JSON.toJSONString(responseBody));
            QueryYXGJCodeBo queryYXGJCodeBo = new QueryYXGJCodeBo();
            if(ResultMapHelper.isSuccess(responseBody)){
                queryYXGJCodeBo = JSON.parseObject(JSON.toJSONString(responseBody.get("data")),QueryYXGJCodeBo.class);
                if(queryYXGJCodeBo.getIsVerifi().equals("01")){
                    queryYXGJCodeBo.setIsDistSuccess(QueryYXGJCodeBo.isDistSuccess_VER);
                }else if(queryYXGJCodeBo.getIsVerifi().equals("00")){
                    queryYXGJCodeBo.setIsDistSuccess(QueryYXGJCodeBo.isDistSuccess_CAN_USE);
                }
            }else {
                if("01".equals(responseBody.get("status").toString())){
                    queryYXGJCodeBo.setIsDistSuccess(QueryYXGJCodeBo.isDistSuccess_NO_EXIST);
                }else if("02".equals(responseBody.get("status").toString())){
                    queryYXGJCodeBo.setIsDistSuccess(QueryYXGJCodeBo.isDistSuccess_NO_EXIST);
                }
            }
            return queryYXGJCodeBo;
        }
        return new QueryYXGJCodeBo();
    }

    public Map<String,Object> handleYXGJVerNo(Integer userId,String code){
        //满减券
        final String TICKET_TYPE_00 = "00";
        //折扣券
        final String TICKET_TYPE_01 = "01";
        //礼品券
        final String TICKET_TYPE_10 = "10";
        QueryYXGJCodeBo queryYXGJCodeBo = new QueryYXGJCodeBo();
        try {
            queryYXGJCodeBo = this.queryYXGJCode(userId,code);
        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
        //测试数据
        if(queryYXGJCodeBo.getIsDistSuccess() == QueryYXGJCodeBo.isDistSuccess_NO){
            return ResultMapHelper.result(UnifiedCodeQueryEnums.IDENTIFICATION_FAILURE);
        }else if(queryYXGJCodeBo.getIsDistSuccess() == QueryYXGJCodeBo.isDistSuccess_VER){
            return ResultMapHelper.result(UnifiedCodeQueryEnums.COUPON_EXPIRE);
        }else if(queryYXGJCodeBo.getIsDistSuccess() == QueryYXGJCodeBo.isDistSuccess_NO_EXIST){
            return ResultMapHelper.result(UnifiedCodeQueryEnums.COUPON_NO_EXIST);
        }
        UnifiedCodeQueryRpVo unifiedCodeQueryRpVo = new UnifiedCodeQueryRpVo();
        unifiedCodeQueryRpVo.setUnifiedType("YXGJ");
        UnifiedCodeQueryRpVo.MddBuyModel mddBuyModel = new UnifiedCodeQueryRpVo.MddBuyModel();
        unifiedCodeQueryRpVo.setDataModel(mddBuyModel);
        mddBuyModel.setActivityName(queryYXGJCodeBo.getActivityName());
        mddBuyModel.setUseTips(queryYXGJCodeBo.getUseTips());
        if(queryYXGJCodeBo.getTicketType().equals(TICKET_TYPE_00)){
            mddBuyModel.setYxgjType(Constants.TICKET_TYPE_MAN_JIAN);
            mddBuyModel.setTitle("满减优惠券");
            String[] useConditionText = queryYXGJCodeBo.getValueStr().split("-");
            mddBuyModel.setUseText(useConditionText[1]);
            mddBuyModel.setConditionText(String.format("满%s可使用",useConditionText[0]));
            List<String> codes = new ArrayList<>();
            codes.add(code);
            mddBuyModel.setCodes(codes);
            mddBuyModel.setExpireTime(String.format("%s-%s",queryYXGJCodeBo.getStartTime(),queryYXGJCodeBo.getEndTime()));
        }else if(queryYXGJCodeBo.getTicketType().equals(TICKET_TYPE_01)){
            mddBuyModel.setYxgjType(Constants.TICKET_TYPE_ZHE_KOU);
            mddBuyModel.setTitle("折扣优惠券");
            String[] useConditionText = queryYXGJCodeBo.getValueStr().split("-");
            mddBuyModel.setUseText(String.format("%s折",useConditionText[1]));
            mddBuyModel.setConditionText(String.format("满%s享%s折",useConditionText[0],useConditionText[1]));
            List<String> codes = new ArrayList<>();
            codes.add(code);
            mddBuyModel.setCodes(codes);
            mddBuyModel.setExpireTime(String.format("%s-%s",queryYXGJCodeBo.getStartTime(),queryYXGJCodeBo.getEndTime()));
        }else if(queryYXGJCodeBo.getTicketType().equals(TICKET_TYPE_10)){
            mddBuyModel.setYxgjType(Constants.TICKET_TYPE_LIN_PIN);
            mddBuyModel.setTitle("礼品优惠券");
            mddBuyModel.setConditionText(String.format("满%s可用",queryYXGJCodeBo.getValueStr()));
            List<String> codes = new ArrayList<>();
            codes.add(code);
            mddBuyModel.setCodes(codes);
            mddBuyModel.setExpireTime(String.format("%s-%s",queryYXGJCodeBo.getStartTime(),queryYXGJCodeBo.getEndTime()));
            mddBuyModel.setPrizeName(queryYXGJCodeBo.getPrizeName());
        }
        return ResultMapHelper.success(unifiedCodeQueryRpVo,ResultMsg.MSG_GET_SUCCESS
        );
    }

    private Map<String, Object> handleSaasztVerNo(Integer userId, String couponCode) {
        JSONObject resultJson = new JSONObject();
        try {
            RequestHeaderData requestHeaderData = new RequestHeaderData();
            String token = requestHeaderData.getString("token");
            Map<String,Object> saasHeader = utilsCommonService.getSaasHeader(userId,token);

            String getUrl = String.format("%s?selfTakeCode=%s",AppConfig.getProperty("saas.domain") + "/api-order/auth/getSelfTakeOrder",couponCode);
            Map<String,Object> params = new HashMap<>();
            resultJson = JSON.parseObject(RestTemplateUtils.getForEntity(getUrl,params,saasHeader));
            log.info("handleSaasztVerNo：{}",resultJson.toJSONString());
        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
        if(resultJson.containsKey("status") && resultJson.containsKey("msg")) {
            if (!(resultJson.containsKey("status") && ResultCode.CODE_NORMAL.equals(resultJson.getString("status")))) {
                return ResultMapHelper.result(ResultCode.CODE_ERROR_100, resultJson.getString("msg"));
            }
        }
        if(!resultJson.containsKey("status")){
            return ResultMapHelper.result(UnifiedCodeQueryEnums.IDENTIFICATION_FAILURE);
        }
        JSONObject resultDataBody = resultJson.getJSONObject("data");
        UnifiedCodeQueryRpVo unifiedCodeQueryRpVo = new UnifiedCodeQueryRpVo();
        unifiedCodeQueryRpVo.setUnifiedType(Constants.CODE_TYPE_SAASZT);
        UnifiedCodeQueryRpVo.MddBuyModel mddBuyModel = new UnifiedCodeQueryRpVo.MddBuyModel();
        mddBuyModel.setSaasztOrderNo(resultDataBody.getString("orderSn"));
        mddBuyModel.setSaasztData(resultDataBody.getString("receiverName") + " " + resultDataBody.getString("receiverPhone"));
        mddBuyModel.setSaasztTime(resultDataBody.getString("expectedTime"));
        mddBuyModel.setSaasztGoodNum(resultDataBody.getInteger("goodsCount"));
        mddBuyModel.setSaasztPriceTotal("￥" + resultDataBody.getBigDecimal("totalAmount").toString());
        mddBuyModel.setSaasztOrderId(resultDataBody.getString("id"));
        unifiedCodeQueryRpVo.setDataModel(mddBuyModel);
        mddBuyModel.getCodes().add(couponCode);
        return ResultMapHelper.success(unifiedCodeQueryRpVo);
    }

    public Map<String,Object> handleMddVerNo(UnifiedCodeQueryVo unifiedCodeQueryVo,UnifiedCodeQueryBo unifiedCodeQueryBo){
        if(StringUtils.isBlank(unifiedCodeQueryBo.getVerNo())){
            return ResultMapHelper.result(UnifiedCodeQueryEnums.IDENTIFICATION_FAILURE);
        }
        SearchDto searchDto = new SearchDto();
        searchDto.setCode(unifiedCodeQueryBo.getVerNo());
        searchDto.setBusinessUserId(unifiedCodeQueryVo.getUserId());
        if(unifiedCodeQueryVo.getBusinessId() == null){
            unifiedCodeQueryVo.setBusinessId(dankMerchantsDefBusinessService.getChooseBusinessId(unifiedCodeQueryVo.getUserId()));
        }
        searchDto.setBusinessId(unifiedCodeQueryVo.getBusinessId());
        if(unifiedCodeQueryVo.getBusinessId() == null){
            //判断是否是店员
            return ResultMapHelper.result(UnifiedCodeQueryEnums.COUPON_NO_EXIST);
        }
        RpcResponseVo rpcResponseVo = couponRestService.searchByVerNo(searchDto);
        if(!rpcResponseVo.isSuccess()){
            if(rpcResponseVo.getStatus().equals(ResultCode.CODE_ERROR_05)){
                return ResultMapHelper.result(UnifiedCodeQueryEnums.COUPON_NO_EXIST);
            }
            return ResultMapHelper.result(UnifiedCodeQueryEnums.IDENTIFICATION_FAILURE);
        }
        searchDto = rpcResponseVo.parseObject(SearchDto.class);
        List<SearchDto.Code> codes = searchDto.getCodes();
        if(CollectionUtils.isEmpty(codes)){
            return ResultMapHelper.result(UnifiedCodeQueryEnums.COUPON_NO_EXIST);
        }
        int countCanUse = 0;
        List<String> canUseCodes = new ArrayList<>();
        for(SearchDto.Code code : codes){
            if(code.getStatus() == Constants.MDD_CODE_NO_USE){
                canUseCodes.add(code.getCodeNumber());
                countCanUse++;
            }
            if(code.getStatus() == Constants.MDD_CODE_NO_DATE_TO_USE){
                return ResultMapHelper.result(UnifiedCodeQueryEnums.COUPON_NO_TIME_USE);
            }
        }
        if(countCanUse == 0){
            return ResultMapHelper.result(UnifiedCodeQueryEnums.COUPON_EXPIRE);
        }
        UnifiedCodeQueryRpVo unifiedCodeQueryRpVo = new UnifiedCodeQueryRpVo();
        UnifiedCodeQueryRpVo.MddBuyModel mddBuyModel =  BeanUtils.copyProperties(searchDto, UnifiedCodeQueryRpVo.MddBuyModel.class);
        mddBuyModel.setCodes(canUseCodes);
        if(searchDto.getCodeType().equals(Constants.CODE_TYPE_MDD_BUY)) {
            mddBuyModel.setGroupPhotos(searchDto.getBmsGroupBuy().getGroupPhotos());
            mddBuyModel.setExpireTime(String.format("有效期至%s", DateTimeUtils.converDateToString(DateTimeUtils.converLocalDateTimeToDate(searchDto.getBmsGroupBuy().getExpireTime()),DateTimeUtils.DATE_PATTERN_DAY)));
            mddBuyModel.setGroupPrice(searchDto.getBmsGroupBuy().getGroupPrice());
            mddBuyModel.setGroupValue(searchDto.getBmsGroupBuy().getGroupValue());
            mddBuyModel.setTitle(searchDto.getBmsGroupBuy().getGroupBuyName());
        }else if(searchDto.getCodeType().equals(Constants.CODE_TYPE_MDD_RECE)){

        }
        unifiedCodeQueryRpVo.setDataModel(mddBuyModel);
        unifiedCodeQueryRpVo.setUnifiedType(Constants.CODE_TYPE_MDD);
        //查询详情
        //System.out.println(unifiedCodeQueryRpVo);
        return ResultMapHelper.success(unifiedCodeQueryRpVo, ResultMsg.MSG_GET_SUCCESS);
    }

    @Override
    public Map<String, Object> unifiedVoucherCode(UnifiedCodeQueryVo unifiedCodeQueryVo) {
        List<String> codes = unifiedCodeQueryVo.getInputCodes();
        if(CollectionUtils.isEmpty(codes)){
            return ResultMapHelper.result(ResultCode.CODE_ERROR_100,ResultMsg.MSG_VER_CODE_NO_EMPTY);
        }
        String code = codes.get(0);
        if(code.startsWith(Constants.CODE_MARKETING_TOOLS)){
            //TODO营销工具的码
            return handleMarketingTools(unifiedCodeQueryVo.getUserId(),code);
        }else if(code.startsWith(Constants.CODE_SAAS_ZT)){
            return handleSaasZt(unifiedCodeQueryVo.getUserId(),code);
        } else {
            VerByNoDto verByNoDto = new VerByNoDto();
            verByNoDto.setCodes(unifiedCodeQueryVo.getInputCodes());
            verByNoDto.setUserId(unifiedCodeQueryVo.getUserId());
            if(unifiedCodeQueryVo.getScanTip() != null && unifiedCodeQueryVo.getScanTip() == Constants.COMMON_FLAG_TRUE_INT){
                verByNoDto.setVerWay(unifiedCodeQueryVo.getScanTip());
            }
            RpcResponseVo rpcResponseVo = couponRestService.verByNo(verByNoDto);
            if(!rpcResponseVo.isSuccess()){
                return ResultMapHelper.result(rpcResponseVo.getStatus(),rpcResponseVo.getMsg());
            }
        }
        return ResultMapHelper.success(new HashMap<>(),ResultMsg.HAND_SUCCESS);
    }



    private Map<String,Object> handleMarketingTools(Integer userId,String couponCode){
        try {
            GetMidongdongUserDto getMidongdongUserDto = new GetMidongdongUserDto();
            getMidongdongUserDto.setUserId(userId);
            RpcResponseVo rpcResponseVo = userRestService.getMidongdongUser(getMidongdongUserDto);
            if(rpcResponseVo.isSuccess()){
                getMidongdongUserDto = rpcResponseVo.parseObject(GetMidongdongUserDto.class);
                log.info("accountId :{}",getMidongdongUserDto.getAccountId());
                Map<String,Object> responseBody = yxgjService.verificationPrize(getMidongdongUserDto.getAccountId(),couponCode);
                log.info("verificationPrize : " + JSON.toJSONString(responseBody));
                if(!ResultMapHelper.isSuccess(responseBody)){
                    return ResultMapHelper.result(ResultCode.CODE_ERROR_100,responseBody.get("msg").toString());
                }
                return ResultMapHelper.success(new HashMap<>(),ResultMsg.HAND_SUCCESS);
            }
        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
        return ResultMapHelper.result(ResultCode.CODE_ERROR_100,ResultMsg.HAND_FAIL);
    }

    private Map<String,Object> handleSaasZt(Integer userId, String code) {
        try {
            RequestHeaderData requestHeaderData = new RequestHeaderData();
            String token = requestHeaderData.getString("token");
            Map<String,Object> saasHeader = utilsCommonService.getSaasHeader(userId,token);

            String getUrl = String.format("%s?selfTakeCode=%s",AppConfig.getProperty("saas.domain") + "/api-order/auth/selfTakeHeXiao",code);
            Map<String,Object> params = new HashMap<>();
            JSONObject resultJson = JSON.parseObject(RestTemplateUtils.postForEntity(getUrl,params,saasHeader));
            log.info("handleSaasZt：{}",resultJson.toJSONString());
            if(!(resultJson.containsKey("status") && ResultCode.CODE_NORMAL.equals(resultJson.getString("status")))){
                return ResultMapHelper.result(ResultCode.CODE_ERROR_100,resultJson.getString("msg"));
            }
            return ResultMapHelper.success(new HashMap<>(),ResultMsg.HAND_SUCCESS);
        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
        return ResultMapHelper.result(ResultCode.CODE_ERROR,ResultMsg.HAND_FAIL);
    }

    @Override
    public Map<String, Object> getMddGroupBuyCouponDetail(UnifiedCodeQueryVo unifiedCodeQueryVo) {
        SearchCouponDetailDto searchCouponDetailDto = new SearchCouponDetailDto();
        searchCouponDetailDto.setVerId(unifiedCodeQueryVo.getVerId());
        RpcResponseVo rpcResponseVo = couponRestService.searchCouponDetail(searchCouponDetailDto);
        if(!rpcResponseVo.isSuccess()){
            if(rpcResponseVo.getStatus().equals(ResultCode.CODE_ERROR_05)){
                return ResultMapHelper.result(ResultCode.CODE_ERROR_05,ResultMsg.CODE_ERROR_05);
            }
        }
        searchCouponDetailDto = rpcResponseVo.parseObject(SearchCouponDetailDto.class);
        SearchConsumerCouponDetailRpVo searchConsumerCouponDetailRpVo = BeanUtils.copyProperties(searchCouponDetailDto,SearchConsumerCouponDetailRpVo.class);
        if(searchCouponDetailDto.getBuyDetailData() != null) {
            searchConsumerCouponDetailRpVo.setBuyDetailData(BeanUtils.copyProperties(searchCouponDetailDto.getBuyDetailData(), SearchConsumerCouponDetailRpVo.BmsGroupBuyDetailData.class));
            searchConsumerCouponDetailRpVo.getBuyDetailData().setBusiness(BeanUtils.copyProperties(searchCouponDetailDto.getBuyDetailData().getBusinessData(), SearchConsumerCouponDetailRpVo.BusinessData.class));
        }
        if(searchCouponDetailDto.getUserReceDetailData() != null){
            searchConsumerCouponDetailRpVo.setUserReceDetailData(BeanUtils.copyProperties(searchCouponDetailDto.getUserReceDetailData(), SearchConsumerCouponDetailRpVo.UserReceDetailData.class));
            searchConsumerCouponDetailRpVo.getUserReceDetailData().setBusiness(BeanUtils.copyProperties(searchCouponDetailDto.getUserReceDetailData().getBusiness(), SearchConsumerCouponDetailRpVo.BusinessData.class));
            if(StringUtils.isBlank(searchConsumerCouponDetailRpVo.getUserReceDetailData().getCouponDesc())){
                searchConsumerCouponDetailRpVo.getUserReceDetailData().setCouponDesc("");
            }
        }
        GetMddGroupBuyCouponDetailRpVo getMddGroupBuyCouponDetailRpVo = new GetMddGroupBuyCouponDetailRpVo();
        GetMddGroupBuyCouponDetailRpVo.GetMddGroupBuyCouponDetailRpGroupBuy groupBuyData = BeanUtils.copyProperties(searchConsumerCouponDetailRpVo.getBuyDetailData(), GetMddGroupBuyCouponDetailRpVo.GetMddGroupBuyCouponDetailRpGroupBuy.class);
        groupBuyData.setBusinessData(BeanUtils.copyProperties(searchConsumerCouponDetailRpVo.getBuyDetailData().getBusiness(), SearchCouponDetailDto.BusinessData.class));
        getMddGroupBuyCouponDetailRpVo.setGroupBuyData(groupBuyData);
        return ResultMapHelper.success(getMddGroupBuyCouponDetailRpVo,ResultMsg.MSG_GET_SUCCESS);
    }
}
